<?php

	function https_request($url,$data=null){
	
		$curl = curl_init();
		curl_setopt($curl, CURLOPT_URL, $url);

		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false );
		curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false );
		
		if(!empty($data)){
		
		    curl_setopt($curl, CURLOPT_POST, 1);
			curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
			

		}
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1 );
		$output = curl_exec($curl);
		curl_close($curl);
		

		return $output;
	}
	
	function get_token(){
		$appid = "wx0d8496a77ea3ec84";
		$secret = "ef3a83b965135f4e8cac60d2e2aab6f5";
	
		$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}";
		$json = https_request($url);

		$arr = json_decode($json,true);
		
		return $arr[access_token];
		
	}
	
	